/**     
* @Title: RoleServiceImpl.java
* @Package me.springboot.security.service.impl 
* @Description: TODO
* @author weiwei 
* @date 2017/08/29
* @version V1.0     
*/
package me.springboot.security.service.impl;

import me.springboot.core.AbstractService;
import me.springboot.security.dao.RoleMapper;
import me.springboot.security.model.Role;
import me.springboot.security.service.RoleService;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import java.util.List;

import javax.annotation.Resource;

/**
 * @ClassName: RoleService
 * @Description: TODO
 * @author weiwei
 * @date 2017/08/29
 */
@Service
@Transactional
public class RoleServiceImpl extends AbstractService<Role> implements RoleService {

	@Resource
	private RoleMapper roleMapper;

	@Override
	public Role findByUserId(Integer userId) {
		if (null != userId) {
			List<Role> roles = roleMapper.queryByUserId(userId);
			if (!CollectionUtils.isEmpty(roles)) {
				roles.get(0);
			}
		}
		return null;
	}

}